package com.dq.domain.sys.user.user.centre;

import com.dq.domain.base.BaseEntity;
import com.dq.domain.org.Org;
import com.dq.domain.org.OrgCustomerLevel;
import com.dq.domain.sys.menu.SysMenu;
import com.dq.domain.sys.section.SysSection;
import com.dq.domain.sys.user.UserHobby;
import com.dq.domain.sys.user.user.StaffUser;
import com.dq.domain.sys.user.user.base.FrontUser;
import com.dq.exception.customException.AdminException;
import com.dq.utils.AgeUtils;
import com.dq.utils.EditCheckUtil;
import com.dq.utils.TimeUtil;
import com.dq.vo.baseVo.VO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Set;

import static com.dq.vo.baseVo.VO.inCaseNull;

/**
 * @author cf
 */
@Data
@Entity
@ApiModel("用户标签")
public class UserLable extends BaseEntity implements VO.ToVO {
    @ApiModelProperty("标签名称")
    @Column(unique = true)
    @NotBlank
    protected String name;

    /** 标签类型, 顾客标签, 员工标签 */
    @ApiModelProperty("类型")
    @Enumerated(EnumType.STRING)
//    @NotBlank 放到代码中验证, 避免穿参必传
    protected LableType type;

    public enum LableType {
        /** 标签类型, 顾客标签, 员工标签 */
        one("顾客"),
        two("技师"),;

        LableType(String name) {
            this.name = name;
        }
        public String name;
    }

    @Data
    @ApiModel(value = "视图")
    public static class Vo implements VO {
        protected Long id;
        @ApiModelProperty("标签名称")
        protected String name;
        @ApiModelProperty("类型")
        private String typeCn;
        private String typeZn;

        @ApiModelProperty(value = "创建人")
        private Long createUserId;
        private String createUserName;

        @ApiModelProperty(value = "创建时间")
        private String createTime;
    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.getId();
        vo.name = fmt(this.getName());
        vo.typeCn = this.getType() == null ? "" : this.getType().name;
        vo.typeZn = this.getType() == null ? "" : this.getType().toString();

        vo.createUserId = this.getCreateUser() == null ? null : this.getCreateUser().getId();
        vo.createUserName = this.getCreateUser() == null ? "" : this.getCreateUser().getUserRealcName();
        vo.createTime = fmt(this.getCreateTime(), TimeUtil.YYYY_MM_DD_HH_MM_SS);

        return vo;
    }
}
